﻿using System.Linq;
using ZilLion.Core.Unities.UnitiesMethods.WebApi.Http;
using ZilLion.Task.Domain.Taskmanager.Entity;
using ZilLion.Task.Domain.Taskmanager.Response;
using ZilLion.Task.Domain.WebEntity;

namespace ZilLion.Task.Domain.Taskmanager.Repository
{
    public class TaskConfigRespository : WebApiRepositoryBase<HttpNoCompressionClient>
    {
        public TaskConfigResponse GetConfigResponse()
        {
            var url =
                @"Api/TaskConfig/GetAllTaskConfig";
            return HttpGet<TaskConfigResponse>(url);
        }

        public bool DownLoadPackage(string mouduleid, string savepath)
        {
            var url =
                $"{HostUrl}/Api/DownloadTaskPackage/{mouduleid}";
            return DownloadFile(url,
                savepath);
        }

        public bool SaveConfig(TaskConfig entity)
        {
            var url =
                @"Api/TaskConfig/SaveTaskConfig";
            var response = HttpPost<TaskConfig, ResponseResultInfo>(entity, url);

            return (response != null) && response.IsSuccess;
        }

        public TaskConfigResponse GetTaskConfigById(string taskid)

        {
            var url =
                $"Api/TaskConfig/GetTaskConfig/{taskid}";

            return HttpGet<TaskConfigResponse>(url);

          
        }
    }
}